<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <title>文档详情</title>

    <link rel="stylesheet" href="${ctx}/static/styles/std_detail.css" type="text/css">
    <script src="${ctx}/static/js/pdfobject.min.js"></script>

    <c:if test="${!empty exists}">
        <script>
            document.onreadystatechange = function () {
                if (document.readyState == "complete") {
                    PDFObject.embed("${ctx}/resource/docs/${doc.location}", "#example");
                }
            }
        </script>
    </c:if>
</head>

<body>
<div class="std-main">
    <div class="container">
        <h5>文档详情</h5>
        <div class="std-detail">
            <div class="std-name">
                <h2>文档标题：${doc.title}</h2>
                <p>作者：${doc.authors}</p>
            </div>
            <div class="std-info">
                <p>摘要：${doc.summary}</p>
                <p>关键词：${doc.keywords}</p>
                <p>文档上传时间：<fmt:formatDate value="${doc.createDate}" type="date" dateStyle="long"/></p>
                <p>文档年份：<fmt:formatDate value="${doc.docTime}" type="date" dateStyle="long"/></p>
            </div>
        </div>
        <a class="std-detail-another" data-toggle="modal" data-target="#myModal">
            查看OCR全文
        </a>
        <c:if test="${!empty htmlExists}">
            <a class="std-detail-another" data-toggle="modal" data-target="#myModalHtml">
                查看html
            </a>
        </c:if>
        <c:if test="${!empty xmlExists}">
            <a class="std-detail-another" data-toggle="modal" data-target="#myModalXml">
                查看xml
            </a>
        </c:if>
        <div>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PDF:
        </div>
        <c:if test="${!empty exists}">
            <div id="example" style="height: 500px; width: 600px;">

            </div>
        </c:if>
        <c:if test="${empty exists}">
            <div id="example">
                <p>该文档不存在PDF。</p>
            </div>
        </c:if>

        <!-- Button trigger modal -->
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">关闭</span></button>
                <h4 class="modal-title" id="myModalLabel">OCR文本详情</h4>
            </div>
            <div class="modal-body">
                ${doc.content}
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary">保存修改</button>
            </div>
        </div>
    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModalHtml" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">关闭</span></button>
                <h4 class="modal-title" id="myModalLabelHtml">HTML</h4>
            </div>
            <div class="modal-body">
                ${doc.htmlTextPure}
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary">保存修改</button>
            </div>
        </div>
    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModalXml" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">关闭</span></button>
                <h4 class="modal-title" id="myModalLabelXML">XML</h4>
            </div>
            <div class="modal-body">
                ${doc.xmlTextPure}
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary">保存修改</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
